<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            id: 1,
            age: 12,
            name: 'lisi',
            address: '羊村'
        }

        // 获得 id, age, name
        // let {id, age, name} = obj;
        // console.log(id, age, name);

        // 仅仅获得 id
        let { id } = obj;
        console.log(id);

        // 完整写法
        let { age: age, address: address } = obj;
        console.log(age, address);

        // 将 name 改为 uname
        let { name: uname } = obj;
        console.log(uname);

        // 练习

        const obj2 = {
            data: {
                code: 10000,
                message: '频道链表获取成功',
                result: ['HTML', 'CSS', 'JavaScript', 'Vue', 'SprintBoot']
            },
            status: 200,
            statusText: 'Ok'
        }

        // 获取 code message 将 result 变为 list
        let {data} = obj2;
        let {code, message, result:list} = data;
        console.log(code, message, list);
        
    </script>
</body>

</html>